## IDL ................................................ module HelloApp { interface Hello { string sayHello(); }; }; ## kli ................................................ lappend auto_path ./combat-tcl-0.7.4 package re combat #% 0.7 set m [corba::string_to_object file://[pwd]/Hello.ior] #source Hello.tcl #combat::ir add $_ir_Hello # alternatywa... combat::ir add \ { {module {IDL:HelloApp:1.0 HelloApp 1.0} { {interface {IDL:HelloApp/Hello:1.0\ Hello 1.0} {} { {operation {IDL:HelloApp/Hello/sayHello:1.0 sayHello 1.0}\ string {} {}}}}}}} $m sayHello ## ser ................................................ lappend auto_path ./combat-tcl-0.7.4 package require combat #% 0.7 class HelloWorld { inherit PortableServer::ServantBase public method _Interface {} { return "IDL:HelloApp/Hello:1.0" } public method sayHello {} { return "Jak sie masz ???" } } source Hello.tcl combat::ir add $_ir_Hello set obj [HelloWorld #auto] set poa [corba::resolve_initial_references "RootPOA"] [$poa the_POAManager] activate set ref [$poa servant_to_reference $obj] set ior [corba::object_to_string $ref] set f [open Hello.ior "w"]; puts $f $ior; close $f vwait qqq ## kli uzywajacy CosNaming czyli NamingService ................................................ # + NamigService tworzy "drzewo kontekstow" # (kontekst to cos w rodzaju katalogu) # + w kontekstach umieszcza sie obiekty i/lub pod-konteksty # + CosNaming zawiera 2 wazne interfejsy: # NamingContext - glowne operacje # NamingContextExt - pewne ulatwienia, np. resolve_str dla resolve # + pod-konteksty moga pochodzic z innego serwera! # (rozproszony NamingService???) # + opisy CosNaming ??? # spec, java docs, plik idl (COS_ns.idl) source COS_ns.tcl # + COS_ns.tcl to skompilowany przez idl2tcl plik IDL NameService... combat::ir add $_ir_COS_ns set ns [corba::string_to_object http://mhanckow.students.wmi.amu.edu.pl/pliki/nsd.ior] # + podlaczamy sie do serwera z NamingService poprzez plik nsd.ior # listujemy zawartosc kontekstu korzenia ... $ns list 10 x y; join $x \n #% binding_name {{id EventChannelFactory kind {}}} binding_type nobject binding_name {{id PropertySetDefFactory kind {}}} binding_type nobject binding_name {{id PropertySetFactory kind {}}} binding_type nobject binding_name {{id propset1 kind {}}} binding_type nobject set q1 [$ns resolve_str "propset1"] # + $q1 to ref do obiektu Corby, wyciagnieta z NamingService # + mozna uzywac "/" do podania sciezki przez drzewo kontekstow !!! set q1 [$ns resolve {{id "propset1" kind ""}}] # + inny sposob zrobienia tego samego co wyzej... # + argument to tablica struktur NameComponent $ns rebind {{id "qqq1" kind ""}} $q1 # + tworzymy nowy wpis dla tego samego obiektu ! # + rebind dziala jak bind, ale zapisuje stary wpis $ns list 10 x y; join $x \n #% binding_name {{id EventChannelFactory kind {}}} binding_type nobject binding_name {{id PropertySetDefFactory kind {}}} binding_type nobject binding_name {{id PropertySetFactory kind {}}} binding_type nobject binding_name {{id propset1 kind {}}} binding_type nobject binding_name {{id qqq1 kind {}}} binding_type nobject # tworzenie podkontekstu set ctx1 [$ns new_context] $ns bind_context [$ns to_name "katalog1"] $ctx1 # + to_name to metoda, ktora zamienia sciezke z "/" na liste komponentow $ns list 10 x y; join $x \n #% binding_name {{id EventChannelFactory kind {}}} binding_type nobject binding_name {{id PropertySetDefFactory kind {}}} binding_type nobject binding_name {{id PropertySetFactory kind {}}} binding_type nobject binding_name {{id propset1 kind {}}} binding_type nobject binding_name {{id qqq1 kind {}}} binding_type nobject binding_name {{id katalog1 kind {}}} binding_type ncontext $ns rebind [$ns to_name "katalog1/qqq1_raz_jeszcze"] $q1 # + umieszczam obiekt w katalog1 set q1a [$ns resolve_str "katalog1/qqq1_raz_jeszcze"] set q1b [$ns resolve {{id "katalog1" kind {}} {id "qqq1_raz_jeszcze" kind {}}}] set q1c [$ns resolve [$ns to_name "katalog1/qqq1_raz_jeszcze"]] # + wszystkie linijki robia to samo ... set ctx2 [$ns resolve_str "katalog1"] # + $ctx2 to ref do pod-kontekstu "katalog1" $ctx2 list 10 x y; join $x \n #% binding_name {{id qqq1_raz_jeszcze kind {}}} binding_type nobject